/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 62536
 * Date: 2024-06-04
 * Time: 14:25
 */
public class Solution {
    public boolean lemonadeChange(int[] bills) {
        int five = 0, ten = 0;
        for (int bill: bills) {
            if(bill == 5){
                five++;
            } else if (bill == 10) {
                if(five == 0){
                    return false;
                } else {
                    five--;
                    ten++;
                }
            } else {
                if(ten != 0 && five != 0){
                    ten--;
                    five--;
                } else if(five >= 3){
                    five -= 3;
                } else {
                    return false;
                }
            }
        }

        return true;

    }
}
